package one;

import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;

@SuppressWarnings("deprecation")
public class Scenario1 extends SeleneseTestCase {
	public SeleniumServer rs;
	@Before
	public void setUp() throws Exception {
		rs=new SeleniumServer();
		rs.start();
		selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.rightstart.com/");
		
		selenium.start();
	}



	@Test
	public void testUntitled() throws Exception {
		selenium.open("/");
		selenium.windowMaximize();
		selenium.type("id=search","toys");
		selenium.click("class=btn_search");
		selenium.waitForPageToLoad("60000");
		//select product
		selenium.click("id=product_list-small_image-img-564");
		selenium.waitForPageToLoad("60000");
		//select quantity of the product
		selenium.type("id=qty","1");
		//save price of the product
		String price = selenium.getText("product-price-564");
		//print price of the product
		System.out.println("price="+price);
		//Add product to the cart
		selenium.click("class=btn_add_to_cart2");
		//click on view cart and checkout
		
		selenium.click("id=cartHeader");
		selenium.click("css=span > span");
		selenium.waitForPageToLoad("60000");
		
		//save total price --- a
		String priceA = selenium.getText("class=price");
		//scrolldown
		selenium.getEval("window.scrollBy(0,500)");
		//get quote for your state,select value from dropdown
		selenium.select("id=region_id","label=California");
		Thread.sleep(5000);
		selenium.click("type=button");
		//type zipcode
		selenium.type("id=postcode","95051");
		//select shipping option(ground)
		selenium.check("id=s_method_udropship_ground");
		Thread.sleep(5000);
		//click update total
		selenium.click("type=submit");
		selenium.waitForPageToLoad("60000");
		//save grand total ----b
		String priceB = selenium.getText("\\td[@class='a-right']/span");
		//compare A and B values
		if(String(priceA, priceB))
		{
			System.out.println("priceA");
		}
		else
		{
			System.out.println("pricaA!= priceB");
		}
		Thread.sleep(5000);
		//proceed to checkout
		selenium.click("class=button btn-proceed-checkout checkout button");
		
		
		Thread.sleep(5000);
				
			
		
		
		
		
		
		
		
		
		
		
		
		
		
	}

	private boolean String(String priceA, String priceB) {
		// TODO Auto-generated method stub
		return false;
	}



	@After
	public void tearDown() throws Exception {
		selenium.stop();
		rs.stop();
	}
}

